/**
 * 此文件是用来统一管理异步请求
 */

import ajax from './ajax';
import mockAjax from './mockAjax';

// 1. 获取三级导航列表数据
// export const reqGetCategoryListData = () => {
//   return ajax.get('/api/product/getBaseCategoryList');
// };
// 当箭头函数中只有一行代码的时候，可以省略return和{}
export const reqGetCategoryListData = () => ajax.get('/product/getBaseCategoryList');

// 2  获取轮播图的数据
export const reqGetBannerListData = ()=> mockAjax.get('/bannerList')

// 3  获取楼层的数据
export const reqGetFloorsListData = () => mockAjax.get('/floorsList')

// 4  获取search页面的搜索数据
export const reqGetSearchGoodsInfoData = (searchParams)=>ajax.post('/list',searchParams)

// 5 获取详情页面的数据
export const reqGetDetailInfoData = (skuId) => ajax.get('/item/' + skuId)

// 6   添加商品到购物车或是在购物车中更改商品数量
export const reqAddOrUpdateSkuInfoToShopCart = (skuId,skuNum)=>ajax.post(`/cart/addToCart/${ skuId }/${ skuNum }`)

// 7   获取购物车中的商品数据
export const reqGetShopCartListData=()=>ajax.get('/cart/cartList')

// 8 更新购物车中商品的选中状态  单选中的选中与否
export const reqUpdateSkuInfoState = (skuID,isChecked) => ajax.get(`/cart/checkCart/${skuID}/${isChecked}`)

// 9 批量更新购物车中商品的选中状态
export const reqUpdateAllSkuInfoState = (isChecked,skuIdList) =>ajax.post(`/cart/batchCheckCart/${isChecked}`,skuIdList)

// 10  删除一条商品数据
export const reqDeleteOneCartInfo = (skuId)=> ajax.delete(`/cart/deleteCart/${skuId}`)

// 11  批量删除多条商品数据 
export const reqDeleteSelectedCartInfo = (skuIdList)=>ajax.post(`/cart/batchDeleteCart`,skuIdList)

// 12 获取手机验证码
export const reqGetVerifyCode = (phone)=> ajax.get(`/user/passport/sendCode/${phone}`)

// 13 实现用户注册
export const reqRegisterUser =(user)=> ajax.post(`/user/passport/register`,user)

// 14 实现用户登录
export const reqUserLogin = (userInfo)=> ajax.post('/user/passport/login',userInfo)

// 15  用户退出功能
export const reqUserLogout = ()=> ajax.get('user/passport/logout')

// 16 收件人地址接口
export const reqGetUserAddressListData = () => ajax.get('/user/userAddress/auth/findUserAddressList')

// 17 trade 订单结算中心接口函数
export const reqGetTradeInfoData = ()=> ajax.get('/order/auth/trade')

// 18 提交订单的接口函数
export const reqSubmitOrder = (tradeNo,params)=>ajax.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`,params)

// 19 获取支付链接 
export const reqGetPayQRcode = (orderId)=> ajax.get(`/payment/weixin/createNative/${orderId}`)

// 20. 查询订单支付状态
export const reqQueryPayStatus = (orderId) => ajax.get(`/payment/weixin/queryPayStatus/${orderId}`)

// 21. 查询订单中心列表 就是之前已经支付过钱的商品列表中心
export const reqGetCenterListData = (page,limit)=> ajax.get(`/order/auth/${page}/${limit}`)
